#include "GLError.h"
using namespace OpenGLWrapper;

bool GLException::EnableExceptions = false;
GLError GLException::ThrowException(GLError errCode, std::string errString, void* pContext)
{
	if (EnableExceptions)
		throw GLException(errCode, errString, pContext);
	else
		return errCode;
}

GLException::GLException()
	: _errCode(GLError::GLError_Success)
	, _errString("")
	, _pContext(nullptr)
{

}

GLException::GLException(GLError errCode)
	: _errCode(errCode)
	, _errString("")
	, _pContext(nullptr)
{

}

GLException::GLException(GLError errCode, void* pContext)
	: _errCode(errCode)
	, _errString("")
	, _pContext(pContext)
{

}

GLException::GLException(GLError errCode, std::string errString)
	: _errCode(errCode)
	, _errString(errString)
	, _pContext(nullptr)
{

}

GLException::GLException(GLError errCode, std::string errString, void* pContext)
	: _errCode(errCode)
	, _errString(errString)
	, _pContext(pContext)
{

}

GLException::~GLException()
{
	_errString.clear();
	_pContext = nullptr;
}

GLError GLException::GetErrorCode()
{
	return _errCode;
}

std::string GLException::GetErrorString()
{
	return _errString;
}

void* GLException::GetContext()
{
	return _pContext;
}